package java_test.io;

import java.io.*;

public class Exercise2 {
    public static void main(String[] args) {
        encryption("C:\\Users\\lemon\\Desktop\\0e5c0ea1457e0719547a87e9d70fde97f40837d7.jpg", "C:\\Users\\lemon\\Desktop\\test.jpg");
        encryption("C:\\Users\\lemon\\Desktop\\test.jpg", "C:\\Users\\lemon\\Desktop\\test1.jpg");
    }

    public static void encryption(String scr, String dest) {
        FileInputStream fis = null;
        FileOutputStream fos = null;

        try {
            fis = new FileInputStream(new File(scr));
            fos = new FileOutputStream(new File(dest));

            int b = 0;
            while ((b = fis.read()) != -1) {
                fos.write(b ^ 5);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }

            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
